package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import o.bbl.j;

public class bby {
    public static String ˊ(Context context, String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        if (str.toLowerCase(Locale.US).startsWith("v")) {
            return str;
        }
        return context.getResources().getString(j.ʼ, new Object[]{str});
    }

    public static String ˋ(Context context, @NonNull ApplicationInfo applicationInfo, String str) {
        String str2 = "";
        if (applicationInfo.labelRes != 0) {
            try {
                AssetManager ॱ = cdy.ॱ(str);
                Resources resources = context.getResources();
                return new Resources(ॱ, resources.getDisplayMetrics(), resources.getConfiguration()).getText(applicationInfo.labelRes).toString();
            } catch (NotFoundException e) {
                bbn.ˎ.ˊ("ApkDetailUtils", "can not get labelRes,NotFoundException :" + applicationInfo.labelRes);
            } catch (NoSuchMethodException e2) {
                bbn.ˎ.ˊ("ApkDetailUtils", "can not get labelRes,NoSuchMethodException");
            } catch (IllegalAccessException e3) {
                bbn.ˎ.ˊ("ApkDetailUtils", "can not get labelRes,IllegalAccessException");
            } catch (InvocationTargetException e4) {
                bbn.ˎ.ˊ("ApkDetailUtils", "can not get labelRes,InvocationTargetException");
            } catch (InstantiationException e5) {
                bbn.ˎ.ˊ("ApkDetailUtils", "can not get labelRes,InstantiationException");
            }
        }
        if (TextUtils.isEmpty(str2) && applicationInfo.nonLocalizedLabel != null) {
            str2 = applicationInfo.nonLocalizedLabel.toString();
        }
        if (TextUtils.isEmpty(str2)) {
            return applicationInfo.packageName;
        }
        return str2;
    }
}
